#include "test_list.h"

#ifdef TEST_ARG_RELEASE

#include <den/arg/arg_release.h>

#define TEST_CASE_NAME Den
#define TEST_NUMBER(n) Arg_Release##_##n

#define TEST_ARG_RELEASE_000
#define TEST_ARG_RELEASE_001
#define TEST_ARG_RELEASE_002
#define TEST_ARG_RELEASE_003
#define TEST_ARG_RELEASE_004
#define TEST_ARG_RELEASE_005
#define TEST_ARG_RELEASE_006
#define TEST_ARG_RELEASE_007
#define TEST_ARG_RELEASE_008
#define TEST_ARG_RELEASE_009
#define TEST_ARG_RELEASE_010
#define TEST_ARG_RELEASE_011
#define TEST_ARG_RELEASE_012
#define TEST_ARG_RELEASE_013
#define TEST_ARG_RELEASE_014
#define TEST_ARG_RELEASE_015
#define TEST_ARG_RELEASE_016
#define TEST_ARG_RELEASE_017
#define TEST_ARG_RELEASE_018
#define TEST_ARG_RELEASE_019
#define TEST_ARG_RELEASE_020
#define TEST_ARG_RELEASE_021
#define TEST_ARG_RELEASE_022
#define TEST_ARG_RELEASE_023
#define TEST_ARG_RELEASE_024
#define TEST_ARG_RELEASE_025
#define TEST_ARG_RELEASE_026
#define TEST_ARG_RELEASE_027
#define TEST_ARG_RELEASE_028
#define TEST_ARG_RELEASE_029
#define TEST_ARG_RELEASE_030
#define TEST_ARG_RELEASE_031
#define TEST_ARG_RELEASE_032

//------------------------------------------------------------------------------------------------------//

namespace{

    ArgRelease GetInt() { static int v=10; return v;  }
    void RecievedInt( const ArgRelease& arg )
    {
        EXPECT_EQ(10, arg.Get<int>()        );
        EXPECT_EQ(10, arg.Get<const int>()  );
        EXPECT_EQ(10, arg.Get<const int&>() );
        EXPECT_EQ(10, arg.Get<int&>()       );
    }

    ArgRelease GetPointer1() { static int v=10; static int*p = &v; return p;  }
    ArgRelease GetPointer2() { static int v=10; return &v;  }
    void RecievedPointer( const ArgRelease arg )
    {
        EXPECT_EQ(10, *arg.Get<int*>()            );
        EXPECT_EQ(10, *arg.Get<const int*>()      );
        EXPECT_EQ(10, *arg.Get<int*const>()       );
        EXPECT_EQ(10, *arg.Get<const int*const>() );
    }

    ArgRelease GetConstPointer() { static const int v=10; return &v;  }
    void RecievedConstPointer( ArgRelease arg )
    {
        EXPECT_EQ(10, *arg.Get<const int*>()      );
        EXPECT_EQ(10, *arg.Get<const int*const>() );
    }

    ArgRelease GetArrayReference1()
    {
        static const int v[2] = {33,77};
        return v;
    }
    ArgRelease GetArrayReference2() { static int v[2] = {33,77}; return v; }
    void RecievedArrayReference1( ArgRelease arg )
    {
        const int (&r)[2] = arg.ToArray<const int[2]>();
        EXPECT_EQ(33, r[0] );
        EXPECT_EQ(77, r[1] );
    }
    void RecievedArrayReference2( ArgRelease arg )
    {
        const int (&r)[2] = arg.ToArray<const int(&)[2]>();
        EXPECT_EQ(33, r[0] );
        EXPECT_EQ(77, r[1] );
    }
    void RecievedArrayReference3( ArgRelease arg )
    {
        const int (&r)[2] = arg.ToArray<int[2]>();
        EXPECT_EQ(33, r[0] );
        EXPECT_EQ(77, r[1] );
    }
    void RecievedArrayReference4( ArgRelease arg )
    {
        const int (&r)[2] = arg.ToArray<int(&)[2]>();
        EXPECT_EQ(33, r[0] );
        EXPECT_EQ(77, r[1] );
    }
    void RecievedArrayReference5( ArgRelease arg )
    {
        const int * p = arg.Get<const int*>();
        EXPECT_EQ(33, p[0] );
        EXPECT_EQ(77, p[1] );
    }
    void RecievedArrayReference6( ArgRelease arg )
    {
        const int * p1 = arg.Get<const int*>();
        EXPECT_EQ(33, p1[0] );
        EXPECT_EQ(77, p1[1] );

        int * p2 = arg.Get<int*>();
        EXPECT_EQ(33, p2[0] );
        EXPECT_EQ(77, p2[1] );
    }

}//namespace
//------------------------------------------------------------------------------------------------------//

#ifdef TEST_ARG_RELEASE_000

TEST(TEST_CASE_NAME, TEST_NUMBER(000))
{
    RecievedInt( GetInt() );
    RecievedPointer( GetPointer1() );
    RecievedPointer( GetPointer2() );
    RecievedConstPointer( GetConstPointer() );
    RecievedArrayReference1( GetArrayReference1() );
    RecievedArrayReference2( GetArrayReference1() );
    RecievedArrayReference3( GetArrayReference1() );
    RecievedArrayReference1( GetArrayReference2() );
    RecievedArrayReference2( GetArrayReference2() );
    RecievedArrayReference3( GetArrayReference2() );
    RecievedArrayReference4( GetArrayReference2() );
    RecievedArrayReference6( GetArrayReference1() );
}
#endif // TEST_ARG_RELEASE_000

#ifdef TEST_ARG_RELEASE_001
TEST(TEST_CASE_NAME, TEST_NUMBER(001))
{
    int v = 10;
    ArgRelease a1 = v;
    int re1 = a1;
    EXPECT_EQ(10, re1);

    int* p = &v;
    ArgRelease a2 = p;
    int* re2 = a2;
    EXPECT_EQ(10, *re2);

    int ar[2] = {33,77};
    ArgRelease a3 = ar;

    int (&re3)[2] = a3;
    EXPECT_EQ(33, re3[0]);
    EXPECT_EQ(77, re3[1]);

    ArgRelease a4 = ar;
    int* re4 = a4;
    EXPECT_EQ(33, re4[0]);
    EXPECT_EQ(77, re4[1]);
}
#endif // TEST_ARG_RELEASE_001

#ifdef TEST_ARG_RELEASE_002
#endif // TEST_ARG_RELEASE_002

#ifdef TEST_ARG_RELEASE_003
#endif // TEST_ARG_RELEASE_003

#ifdef TEST_ARG_RELEASE_004
#endif // TEST_ARG_RELEASE_004

#ifdef TEST_ARG_RELEASE_005
#endif // TEST_ARG_RELEASE_005

#ifdef TEST_ARG_RELEASE_006
#endif // TEST_ARG_RELEASE_006

#ifdef TEST_ARG_RELEASE_007
#endif // TEST_ARG_RELEASE_007

#ifdef TEST_ARG_RELEASE_008
#endif // TEST_ARG_RELEASE_008

#ifdef TEST_ARG_RELEASE_009
#endif // TEST_ARG_RELEASE_009

#ifdef TEST_ARG_RELEASE_010
#endif // TEST_ARG_RELEASE_010

#ifdef TEST_ARG_RELEASE_011
#endif // TEST_ARG_RELEASE_011

#ifdef TEST_ARG_RELEASE_012
#endif // TEST_ARG_RELEASE_012

#ifdef TEST_ARG_RELEASE_013
#endif // TEST_ARG_RELEASE_013

#ifdef TEST_ARG_RELEASE_014
#endif // TEST_ARG_RELEASE_014

#ifdef TEST_ARG_RELEASE_015
#endif // TEST_ARG_RELEASE_015

#ifdef TEST_ARG_RELEASE_016
#endif // TEST_ARG_RELEASE_016

#ifdef TEST_ARG_RELEASE_017
#endif // TEST_ARG_RELEASE_017

#ifdef TEST_ARG_RELEASE_018
#endif // TEST_ARG_RELEASE_018

#ifdef TEST_ARG_RELEASE_019
#endif // TEST_ARG_RELEASE_019

#ifdef TEST_ARG_RELEASE_020
#endif // TEST_ARG_RELEASE_020

#ifdef TEST_ARG_RELEASE_021
#endif // TEST_ARG_RELEASE_021

#ifdef TEST_ARG_RELEASE_022
#endif // TEST_ARG_RELEASE_022

#ifdef TEST_ARG_RELEASE_023
#endif // TEST_ARG_RELEASE_023

#ifdef TEST_ARG_RELEASE_024
#endif // TEST_ARG_RELEASE_024

#ifdef TEST_ARG_RELEASE_025
#endif // TEST_ARG_RELEASE_025

#ifdef TEST_ARG_RELEASE_026
#endif // TEST_ARG_RELEASE_026

#ifdef TEST_ARG_RELEASE_027
#endif // TEST_ARG_RELEASE_027

#ifdef TEST_ARG_RELEASE_028
#endif // TEST_ARG_RELEASE_029

#ifdef TEST_ARG_RELEASE_030
#endif // TEST_ARG_RELEASE_030

#ifdef TEST_ARG_RELEASE_031
#endif // TEST_ARG_RELEASE_031

#ifdef TEST_ARG_RELEASE_032
#endif // TEST_ARG_RELEASE_032


#endif


